What is dmd?
The dmd (documentation markdown) npm package is a tool for generating markdown documentation from JSDoc comments in your JavaScript code. It allows you to create well-structured and readable documentation for your projects.
What are dmd's main functionalities?
Generate Markdown Documentation
This feature allows you to generate markdown documentation from JSDoc comments in your JavaScript files. The code sample demonstrates how to use dmd in conjunction with jsdoc-to-markdown to read JSDoc data from a file and convert it into markdown format.
const dmd = require('dmd');
const jsdoc2md = require('jsdoc-to-markdown');
const jsdocData = jsdoc2md.getTemplateDataSync({ files: 'your-file.js' });
const output = dmd(jsdocData);
console.log(output);
Custom Templates
This feature allows you to use custom templates to format the generated markdown documentation. The code sample shows how to define a custom template and use it with dmd to generate documentation.
const dmd = require('dmd');
const jsdoc2md = require('jsdoc-to-markdown');
const jsdocData = jsdoc2md.getTemplateDataSync({ files: 'your-file.js' });
const template = '{{#module}}{{name}}{{/module}}';
const output = dmd(jsdocData, { template: template });
console.log(output);
Helper Functions
This feature allows you to define and use custom helper functions in your templates. The code sample demonstrates how to create a helper function that converts text to uppercase and use it in the generated documentation.
const dmd = require('dmd');
const jsdoc2md = require('jsdoc-to-markdown');
const jsdocData = jsdoc2md.getTemplateDataSync({ files: 'your-file.js' });
const helpers = {
uppercase: function (str) { return str.toUpperCase(); }
};
const output = dmd(jsdocData, { helper: helpers });
console.log(output);
Other packages similar to dmd
jsdoc-to-markdown
jsdoc-to-markdown is a tool that generates markdown documentation from JSDoc comments. It is often used in conjunction with dmd to provide the data that dmd formats into markdown. Unlike dmd, jsdoc-to-markdown focuses on extracting and converting JSDoc comments into a format that can be further processed.
documentation
documentation is a documentation generation tool that supports multiple output formats, including HTML and markdown. It provides a more comprehensive solution compared to dmd, with built-in support for various output formats and more advanced features like linting and validation of JSDoc comments.
docco
docco is a quick-and-dirty documentation generator that produces HTML documentation with source code and comments side-by-side. While it does not generate markdown like dmd, it is useful for creating readable documentation that closely follows the source code.
dmd
dmd (document with markdown) is the default output template for jsdoc-to-markdown. It contains handlebars partials and helpers intended to transform jsdoc-parse output into markdown API documentation.
For more documentation see the jsdoc2md wiki.
Synopsis
To give the most basic example, this input data:
const templateData = [
{
id: "fatUse",
name: "fatUse",
kind: "member",
description: "I am a global variable",
scope: "global"
}
]
run through this command:
const dmd = require('dmd')
dmd(templateData)
produces this markdown output:
<a name="fatUse"></a>
## fatUse
I am a global variable
**Kind**: global variable
© 2014-24 Lloyd Brookes <75pound@gmail.com>.
Tested by test-runner. Documented by jsdoc-to-markdown.